# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=unrar
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=6.1.7
pkgrel=1
pkgdesc='The RAR uncompression program (mingw-w64)'
arch=(any)
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://www.rarlab.com/rar_add.htm'
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc")
source=("https://www.rarlab.com/rar/unrarsrc-${pkgver}.tar.gz"
        0001-fix-makefile.patch
        0002-fix-redefinition.patch
        0003-workaround-comsupp-library.patch)
sha256sums=('de75b6136958173fdfc530d38a0145b72342cf0d3842bf7bb120d336602d88ed'
            '84ab242dd9a5ee03545aa8f64fb63bf9ad99ec8bc7291743a25b1711b2898aff'
            '863a6e418e45e1b5bd1d3495dbd4ae771997e0b72de145c9a4773970ae75d5f9'
            'eb014e09b6803dce69f894a9b8e395339a6fb1e939222afbf6479355ec2d4935')

prepare() {
  cd ${_realname}
  patch -p1 -i "${srcdir}/0001-fix-makefile.patch"
  patch -p1 -i "${srcdir}/0002-fix-redefinition.patch"
  patch -p1 -i "${srcdir}/0003-workaround-comsupp-library.patch"
}

build() {
  cd ${_realname}
  make
}

package() {
  cd ${_realname}
  install -Dm755 unrar.exe "${pkgdir}${MINGW_PREFIX}/bin/unrar.exe"
  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
